<?php

use Biz\model\brand\BrandApplyInfo;

/**
 * 品牌申请留资接口
 * Class RegisterApply
 */
class RegisterApplyAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $brand = $this->getRequest()->getPost('brand', '');
        $company = $this->getRequest()->getPost('company', '');
        $onlineShop = $this->getRequest()->getPost('online_shop', 0);
        $name = $this->getRequest()->getPost('name', '');
        $phone = $this->getRequest()->getPost('phone', '');
        $weixin = $this->getRequest()->getPost('weixin', '');
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (strpos($ua, 'proxyhttp')) {
        } else {
            if (empty($brand) || empty($company) || empty($name) || empty($phone)) {
                throw new \Exception('请填写完整资料');
            }
            $res = BrandApplyInfo::insertData([
                'uid' => $this->uid,
                'brand' => $brand,
                'company' => $company,
                'online_shop' => $onlineShop,
                'name' => $name,
                'phone' => $phone,
                'weixin' => $weixin,
            ]);
        }
        $this->setSuccess([]);
    }
}